home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / gamesrc / connect4 / c4.h < prev    next >
C/C++ Source or Header  |  1994-09-14  |  3KB  |  75 lines

  1. /****************************************************************************/
  2. /**                                                                        **/
  3. /**                          Connect-4 Algorithm                           **/
  4. /**                                                                        **/
  5. /**                            By Keith Pomakis                            **/
  6. /**                     (kppomaki@jeeves.uwaterloo.ca)                     **/
  7. /**                                                                        **/
  8. /**                               Fall, 1993                               **/
  9. /**                                                                        **/
  10. /****************************************************************************/
  11. /**                                                                        **/
  12. /**                  See the file "c4.c" for documentation.                **/
  13. /**                                                                        **/
  14. /****************************************************************************/
  15.  
  16. #ifndef C4_DEFINED
  17. #define C4_DEFINED
  18.  
  19. #define EMPTY   2
  20.  
  21. #ifndef Boolean
  22. #define Boolean unsigned char
  23. #endif
  24.  
  25. #ifndef TRUE
  26. #define TRUE 1
  27. #endif
  28.  
  29. #ifndef FALSE
  30. #define FALSE 0
  31. #endif
  32.  
  33. typedef struct {
  34.  
  35.     char **board;           /* The board configuration of the game state.  */
  36.                             /* board[x][y] specifies the position of the   */
  37.                             /* xth column and the yth row of the board,    */
  38.                             /* where column and row numbering starts at 0. */
  39.                             /* (The 0th row is the bottom row.)            */
  40.                             /* A value of 0 specifies that the position is */
  41.                             /* occupied by a piece owned by player 0, a    */
  42.                             /* value of 1 specifies that the position is   */
  43.                             /* occupied by a piece owned by player 1, and  */
  44.                             /* a value of EMPTY specifies that the         */
  45.                             /* position is unoccupied.                     */
  46.  
  47.     long *(score_array[2]); /* An array specifying statistics on both      */
  48.                             /* players.  score_array[0] specifies the      */
  49.                             /* statistics for player 0, while              */
  50.                             /* score_array[1] specifies the statistics for */
  51.                             /* player 1.  These statistics have little     */
  52.                             /* meaning outside the realm of the local      */
  53.                             /* functions of the "c4.c" file.               */
  54.  
  55.     long num_of_pieces;     /* The number of pieces currently occupying    */
  56.                             /* board spaces.                               */
  57.  
  58. } Game_state;
  59.  
  60.  
  61. /* See the file "c4.c" for documentation on the following functions. */
  62.  
  63. extern void poll(void (*poll_func)(void), long level);
  64. extern void new_game(long width, long height, long num);
  65. extern Boolean make_move(long player, long column);
  66. extern long automatic_move(long player, long level);
  67. extern Game_state get_game_state(void);
  68. extern long score_of_player(long player);
  69. extern Boolean is_winner(long player);
  70. extern Boolean is_tie(void);
  71. extern void win_coords(long player, long *x1, long *y1, long *x2, long *y2);
  72. extern void end_game(void);
  73.  
  74. #endif /* C4_DEFINED */
  75.